<template>
  <el-select v-model="value" @change="callFather" filterable placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.name"
      :value="item.id">
    </el-option>
  </el-select>
</template>
<script>
import axios from "axios";
  export default {
    data() {
      return {
        options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value: this.fatherValue
      }
    },
    props:["fatherValue"],
    created(){
      this.getData();
    },
    watch:{
      //old表示原本的值    new表示准备要变化的值
      fatherValue:function(newValue,oldValue){
        this.value = newValue
        console.log("新值",newValue)
        console.log("旧值",oldValue)
      }
    },
    methods:{
      getData(){
        axios
        .get("/rbacRole/selectChoiseAll")
        .then((res) => {
          console.log("111111111111",res);
          this.options = res.data;
        })
        .catch((res) => {}); 
      },
      callFather(){
         this.$emit('call', this.value)
      }
    },
  }
</script>